/**
  * @author td
  * @date 2018/3/27
  */
object EnumTest {

  object WeekDay extends Enumeration {
    // 申明枚举对外暴露的类型变量
    type abc = Value;
    val Mon = Value("1");
    val Tue = Value("2");
    val Wed = Value("3")
    val Thu = Value("4")
    val Fri = Value("5")
    val Sat = Value("6")
    val Sun = Value("7")
    def checkExists(day: String): Boolean = {
      this.values.exists(_.toString.equals(day))

    }

    def isWorkDay(day: abc): Boolean = {
      !(day == Sat || day == Sun)
    }

    def showAll: Unit = {
      this.values.foreach(println(_))
    }

  }

  def main(args: Array[String]): Unit = {
    printf(WeekDay.checkExists("3")+"\n")

    WeekDay.showAll

    println(WeekDay.isWorkDay(WeekDay.Sun))

    var index = 0;
    for (index <- 10 to 2 by(-1)) {
      println("value of " +index)
    }

  }

  def fun1(msg: String):(String)=>Unit = {
    (name:String) => println(msg+name);
  }


}
